//
//  UIControl+MethodExchange.m
//  OC_Principle
//
//  Created by wangzhipan on 2025/2/11.
//

#import "UIControl+MethodExchange.h"
#import <objc/runtime.h>

@implementation UIControl (MethodExchange)
+ (void)load
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        Method m1 = class_getInstanceMethod([self class], @selector(sendAction:to:forEvent:));
        Method m2 = class_getInstanceMethod([self class], @selector(zy_sendAction:to:forEvent:));
        method_exchangeImplementations(m1, m2);
    });
}

- (void)zy_sendAction:(SEL)action to:(nullable id)target forEvent:(nullable UIEvent *)event
{
    NSLog(@"ZYMethodExchange:: target==%@, action==%s  evnet==%@", target, action, event);
    
    [self zy_sendAction:action to:target forEvent:event];
}

@end
